a25b42
@@ -290,7 +290,7 @@
public class MllpTcpServerConsumer extends DefaultConsumer {
 
 
     void populateHl7DataHeaders(Exchange exchange, Message message, byte[] hl7MessageBytes) {
-        if (exchange != null && exchange.getException() == null) {
+        if (getConfiguration().isHl7Headers() && exchange != null && exchange.getException() == null) {
             if (hl7MessageBytes == null || hl7MessageBytes.length < 8) {
                 // Not enough data to populate anything - just return
                 return;
@@ -315,8 +315,8 @@
public class MllpTcpServerConsumer extends DefaultConsumer {
 
             if (-1 == endOfMSH) {
                 // TODO:  May want to throw some sort of an Exception here
-                log.error("Population of message headers failed - unable to find the end of the MSH segment");
-            } else if (getConfiguration().isHl7Headers()) {
+                log.warn("Population of message headers failed - unable to find the end of the MSH segment");
+            } else {
                 log.debug("Populating the HL7 message headers");
                 Charset charset = getConfiguration().getCharset(exchange);
 
@@ -384,10 +384,11 @@
public class MllpTcpServerConsumer extends DefaultConsumer {
                         }
                     }
                 }
-            } else {
-                log.trace("HL7 Message headers disabled");
             }
+        } else {
+            log.trace("HL7 Message headers disabled");
         }
+
     }
 
 
